FROM ubuntu:14.04.2
MAINTAINER Doro Wu <fcwu.tw@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
ENV HOME /root

RUN apt-get update \
    && apt-get install -y --force-yes --no-install-recommends supervisor \
        openssh-server pwgen sudo vim-tiny \
        net-tools \
        lxde x11vnc xvfb \
        gtk2-engines-murrine ttf-ubuntu-font-family \
        libreoffice firefox \
        fonts-wqy-microhei \
        language-pack-zh-hans language-pack-gnome-zh-hans firefox-locale-zh-hans libreoffice-l10n-zh-cn \
        nginx \
        python-pip python-dev build-essential automake autoconf \
    && apt-get autoremove \
    && apt-get autoclean

ADD https://dl.dropboxusercontent.com/u/23905041/x11vnc_0.9.14-1.1ubuntu1_amd64.deb /tmp/
ADD https://dl.dropboxusercontent.com/u/23905041/x11vnc-data_0.9.14-1.1ubuntu1_all.deb /tmp/
RUN dpkg -i /tmp/x11vnc*.deb

ADD web /web/
RUN pip install -r /web/requirements.txt

ADD noVNC /noVNC/
ADD nginx.conf /etc/nginx/sites-enabled/default
ADD startup.sh /
ADD supervisord.conf /etc/supervisor/conf.d/

RUN export LC_ALL=zh_CN.UTF-8
RUN export LANGUAGE=zh_CN.UTF-8
RUN export LANG=zh_CN.UTF-8
RUN locale-gen zh_CN.UTF-8
RUN dpkg-reconfigure locales

RUN echo "export LC_ALL=zh_CN.UTF-8" >> /etc/profile
RUN echo "export LANGUAGE=zh_CN.UTF-8" >> /etc/profile
RUN echo "export LANG=zh_CN.UTF-8" >> /etc/profile

EXPOSE 6080
EXPOSE 80
WORKDIR /root
ENTRYPOINT ["/startup.sh"]